<?php
// include function files for this application
require_once('/home/domains/uny-con.com/public_html/uny-con_fns.php');
if (!session_id()) { session_start(); }

//get some variables:
if (isset($_GET['search_key']) && !empty($_GET['search_key'])) $search_key = $_GET['search_key'];
if (isset($_GET['search_string']) && !empty($_GET['search_string'])) {
	if ($_GET['search_key'] == 'attendee_id') {
		$search_string = $_GET['search_string'];
		} else {
		$search_string = '%'.$_GET['search_string'].'%';
		}
	} else {
	$search_string = '%' ;
	}
if (isset($_GET['sortkey'])) $sortkey = $_GET['sortkey'];
if (isset($_GET['sortdir'])) $sortdir = $_GET['sortdir'];


//This is an admin only script so first lets check to make sure the user is valid and an admin. then we can do toher stuff.

if (!check_valid_user() || ($_SESSION['admin'] != 't')) {
	do_html_header('Unauthorized access', staysmall, $uny);
	echo 'You are not logged in or are not authorized to view this page. Please move along.';

	do_html_footer(news);
	exit;
	}

if (empty($search_key) || empty($search_string)) {
	do_html_header('Error', staysmall, $uny);
	echo "You must specify both a search key and search string.<br />\n";
	print_brs(24);
	do_html_footer(news);
	exit;
	}

if (isset($search_key) && isset($search_string)) {
	if (!isset($sortkey)) $sortkey = 'last_name';
	if (!isset($sortdir)) $sortdir = 'ASC';
	$result_values =get_attendees($search_key, $search_string, $sortkey, $sortdir);
	if (count($result_values) == '1' && $search_key == 'attendee_id') {
		header("Location: ".$conf['base_path']."registration/attendee_home.php?attendee_id=$search_string");
		exit;
		}
	do_html_header('Attendee Search Results', gobig, $uny);
	echo "Here are the results of your search for $search_string in the $search_key field<br />\n";
	print_attendee_search_form();
	echo "<br />\n";
	print_attendee_table($result_values);
	do_html_footer(no_news);
	}

?>